package com.jiuling.singleton;

public class LazySingletonTest {
	public static void main(String[] args) {
		for(int i=0;i<10;i++) {
			new Thread(()->{
				LazySingleton single1 =  LazySingleton.getInstance();
				System.out.println(single1);
			}).start();
			new Thread(()->{
				LazySingleton single2 =  LazySingleton.getInstance();
				System.out.println(single2);
			}).start();
		}
	}
}

class LazySingleton{
	private static LazySingleton instance;
	public static LazySingleton getInstance() {
		if(null == instance) {
			synchronized (LazySingleton.class) {
				if(null == instance) {
					instance = new LazySingleton();
				}
			}
		}
		return instance;
	}
}

class NotSingleton{
	
}
